#!/bin/bash

	echo "=========== BUILD SQUID ===========";

	echo "1. Distclean";
    make distclean;
    
    echo "2. Bootstrap";
    sh ./bootstrap.sh; 
    
    echo "3. Configure";
    ./configure '--build=x86_64-linux-gnu' 'build_alias=x86_64-linux-gnu' '--prefix=/usr' '--includedir=${prefix}/include' '--mandir=${prefix}/share/man' '--infodir=${prefix}/share/info' '--sysconfdir=/etc' '--localstatedir=/var' '--libexecdir=${prefix}/lib/squid3' '--disable-maintainer-mode' '--disable-dependency-tracking' '--srcdir=.' '--datadir=/usr/share/squid3' '--sysconfdir=/etc/squid3' '--mandir=/usr/share/man' '--with-cppunit-basedir=/usr' '--enable-inline' '--enable-async-io=64' '--enable-storeio=aufs' '--enable-diskio=AIO,Blocking,DiskDaemon,DiskThreads' '--enable-removal-policies=heap,lru' '--enable-digest-pools' '--enable-snmp' '--enable-htcp' '--disable-carp' '--enable-large-files' '--enable-underscores' '--with-filedescriptors=131072' '--enable-linux-netfilter' '--with-default-user=squid' '-enable-follow-x-forwarded-for';
    
    echo "4. Make";
    make -j 300; 
    
    if [ $? != 0 ]; then echo "Compilation FAILED!!!"; exit; fi;
    
    echo "5. Kill SQUID";
    sh ./kill_squid.sh
    
    echo "6. Deploy";
    checkinstall -y -d 0;
    
    echo "7. Start service";
    /etc/init.d/squid3 start;
    
    echo "8. Log";
    tail -f /var/log/squid3/cache.log;
    